package cn.com.nes.site.module.service;

import java.sql.Connection;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.dao.ExpandDaoImpl;
@Service
public class ExpandService {
	@Resource
	private ExpandDaoImpl impl;

	public PageData getExpandList(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getExpandList(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
	public PageData saveExpand(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.saveExpand(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
    }
	
	public PageData delExpand(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.delExpand(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			} 
		}
		return res ;
    }
	
	public PageData getExpandId(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getExpandId(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}
	
}
